<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>11canvas折线图-绘制点</title>
</head>
<style>
    canvas {
        border: 1px solid #ccc;
    }
</style>
<body>
<canvas width="600" height="400"></canvas>
<script>
    var myCanvas = document.querySelector('canvas');
    var ctx = myCanvas.getContext('2d');
    /*1.绘制点*/
    /*2.点的尺寸*/
    /*3.以坐标中心绘制点*/
    var coordinate = {
        x: 100,
        y: 100,
    };
    /*4.点尺寸*/
    var dottedSize = 6;
    ctx.moveTo(coordinate.x - dottedSize / 2, coordinate.y - dottedSize / 2);
    ctx.lineTo(coordinate.x + dottedSize / 2, coordinate.y - dottedSize / 2);
    ctx.lineTo(coordinate.x + dottedSize / 2, coordinate.y + dottedSize / 2);
    ctx.lineTo(coordinate.x - dottedSize / 2, coordinate.y + dottedSize / 2);
    ctx.closePath();
    ctx.fill();
    ctx.stroke();
</script>
</body>
</html>

